﻿using System;
using System.Collections.Generic;

class ArrayOfStrings
{
    static void Main()
    {
        Console.WriteLine("Enter how many string you want to have in the array:");
        int dimention = int.Parse(Console.ReadLine());
        string[] arrayOfString = new string[dimention];
        for (int index = 0; index < dimention; index++)
        {
            Console.WriteLine("Enter string {0}:",index);
            arrayOfString[index] = Console.ReadLine();
        }
        Console.WriteLine();
        Console.WriteLine("The array you entered is:");
        for (int i = 0; i < dimention; i++)
        {
            Console.WriteLine(arrayOfString[i]);
            Console.WriteLine();
        }
        string tempString = arrayOfString[0];
        Console.WriteLine("The array sorted by the length of the strings is:");
        for (int i = 0; i < dimention - 1; i++)
        {
            for (int j = 1; j < dimention; j++)
            {
                if (arrayOfString[i].Length > arrayOfString[j].Length)
                {
                    tempString = arrayOfString[j];
                    arrayOfString[j] = arrayOfString[i];
                    arrayOfString[i] = tempString;
                }
                
            }
            
        }
        for (int z = 0; z < dimention; z++)
        {
            Console.WriteLine(arrayOfString[z]);
        } 
    }
}

